In an OpenFlow technology, separation between forwarding and control is implemented, and packet forwarding may be controlled by means of programming on a controller. In the OpenFlow technology, a pipeline including a multi-level flow table is used to perform packet forwarding processing. For the OpenFlow technology, refer to OpenFlow Switch Specification version 1.4.0.
When a packet processing apparatus processes a packet, a procedure of processing the packet may relate to multiple instruction blocks. For example, the packet processing apparatus obtains an identifier of a next instruction block according to a current instruction block. The packet processing apparatus processes the packet according to the next instruction block indicated by the identifier of the next instruction block.
A procedure of processing different packets may relate to a same current instruction block and a same next instruction block. The packet processing apparatus may need to store multiple identifiers of the next instruction block. After a storage location of the next instruction block changes, the packet processing apparatus needs to update the multiple identifiers of the next instruction block, and overheads are relatively high.
For example, a current instruction block corresponding to a packet 1 is an instruction block 1, and a next instruction block corresponding to the packet 1 is an instruction block 2. A current instruction block corresponding to a packet 2 is the instruction block 1, and a next instruction block corresponding to the packet 2 is the instruction block 2. A procedure in which the packet processing apparatus processes the packet 1 includes: obtaining an identifier of the instruction block 2 according to the instruction block 1, and processing the packet 1 according to the instruction block 2 corresponding to the identifier of the instruction block 2. A procedure in which the packet processing apparatus processes the packet 2 includes: obtaining an identifier of the instruction block 2 according to the instruction block 1, and processing the packet 2 according to the instruction block 2 corresponding to the identifier of the instruction block 2. The packet processing apparatus needs to store the identifier of the instruction block 2 related to the procedure of processing the packet 1, and the packet processing apparatus also needs to store the identifier of the instruction block 2 related to the procedure of processing the packet 2. That is, the packet processing apparatus needs to store two identifiers of the instruction block 2. If a storage location of the instruction block 2 changes, the packet processing apparatus needs to update the two identifiers of the instruction block 2, and overheads are relatively high.